﻿using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OrbitOne.Elmah.Presenter
{
    public class NiceCheckBoxList : CheckBoxList
    {
        protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
        {
            writer.RenderBeginTag("span");
            base.RenderItem(itemType, repeatIndex, repeatInfo, writer);
            writer.RenderEndTag();
        }
        public IList<string> SelectedValues
        {
            get
            {
                var selectedItems = new List<string>();
                foreach (ListItem item in Items)
                {
                    if (item.Selected)
                    {
                        selectedItems.Add(item.Value);
                    }
                }
                return selectedItems;
            }
        }
    }

    /*public class ApplicationCheckBox : CompositeControl
    {
        public CheckBox CheckBox;
        public string Application
        {
            get
            {
                var result = ViewState["Application"] as string;

                if (ViewState["Application"] == null)
                    result = "";

                return result;
            }
            set { ViewState["Application"] = value; }
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            CheckBox = new CheckBox
                                      {
                                          ID = Application,
                                          Text = Application,
                                          CssClass = "appcheckbox"
                                      };

            var li = new HtmlGenericControl("li");
            li.Controls.Add(CheckBox);

            Controls.Add(li);
        }
    }*/
}
